package com.ruoyi.cat.service.impl;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.ruoyi.cat.domain.AlipayConfig;
import com.ruoyi.cat.domain.VO.SysOracleVO;
import com.ruoyi.cat.service.AlipayService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.stereotype.Service;


@Service
public class AlipayServiceImpl implements AlipayService {


    @Override
    public AjaxResult scanCodePayOrder(SysOracleVO sysOracleVO) {

        AlipayConfig alipayConfig = getAlipayConfig();

        AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig.getServerUrl(),alipayConfig.getAppId(),
                alipayConfig.getPrivateKey(),alipayConfig.getFormat(),alipayConfig.getCharset(),alipayConfig.getAlipayPublicKey(),alipayConfig.getSignType());




        return null;
    }


    private static AlipayConfig getAlipayConfig() {
        String privateKey  = "<-- 请填写您的应用私钥，例如：MIIEvQIBADANB ... ... -->";
        String alipayPublicKey = "<-- 请填写您的支付宝公钥，例如：MIIBIjANBg... -->";
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
        alipayConfig.setAppId("<-- 请填写您的AppId，例如：2019091767145019 -->");
        alipayConfig.setPrivateKey(privateKey);
        alipayConfig.setFormat("json");
        alipayConfig.setAlipayPublicKey(alipayPublicKey);
        alipayConfig.setCharset("UTF-8");
        alipayConfig.setSignType("RSA2");
        return alipayConfig;
    }
}
